package mumethod;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import muobject.*;

public class ViewFunction implements CountTableRow, GetSelectYear{
	private int tableRowCount;
	private List<Physical> physicals;
	private List<Questionnaire> questionnaires;
	
	public int getTableRowCount() {
		return tableRowCount;
	}
	
	public void setTableRowCount(int tableRowCount) {
		this.tableRowCount = tableRowCount;
	}
	
	public List<Physical> getPhysicals() {
		return physicals;
	}

	public void setPhysicals(List<Physical> physicals) {
		this.physicals = physicals;
	}

	public List<Questionnaire> getQuestionnaires() {
		return questionnaires;
	}

	public void setQuestionnaires(List<Questionnaire> questionnaires) {
		this.questionnaires = questionnaires;
	}
	
//	CountTableRow
	
	
	public void addTableColumnCount(){
		this.tableRowCount = tableRowCount + 1;
	}
	
	public void subTableColumnCount(){
		this.tableRowCount = tableRowCount - 1;
	}
	
//	GetSelectYear
	public Set<String> getYears(){
		Set<String> yearSet = new TreeSet<String>();
		try{
			for(Physical physical : physicals){
				yearSet.add(physical.getYears().toString());
			}
			for(Questionnaire questionnaire : questionnaires){
				yearSet.add(questionnaire.getYears().toString());
			}
		}catch(Exception e){
			System.out.println(e.getMessage());
		}
		Calendar sendTime=Calendar.getInstance(); 
		yearSet.add(String.valueOf(sendTime.get(Calendar.YEAR)));
		return yearSet;
	}
}
